package mc

import (
	"gitee.com/dreamwood/ez-go/db/mgo"
)

const (
	AppVersionEventNew          = "running.AppVersionNew"
	AppVersionEventBeforeCreate = "running.AppVersionBeforeCreate"
	AppVersionEventBeforeUpdate = "running.AppVersionBeforeUpdate"
	AppVersionEventBeforeSave   = "running.AppVersionBeforeCreate running.AppVersionBeforeUpdate"
	AppVersionEventAfterCreate  = "running.AppVersionAfterCreate"
	AppVersionEventAfterUpdate  = "running.AppVersionAfterUpdate"
	AppVersionEventAfterSave    = "running.AppVersionAfterCreate running.AppVersionAfterUpdate"
	AppVersionEventDelete       = "running.AppVersionDelete"

	AppVersionAccessControlEvent = "running.AppVersionAccessControl"
)

func GetAppVersionConfig() *mgo.DocConfig {
	return AppVersion_Config
}

var AppVersion_Config *mgo.DocConfig

func init() {
	AppVersion_Config = NewAppVersionConfig()
}

func NewAppVersionConfig() *mgo.DocConfig {
	return &mgo.DocConfig{
		ContainerKey: "running.AppVersion",
		Fields: []string{
			"name", "app", "dir", "starter", "config", "configFile", "logs", "ftpOpen", "ftpPort", "ftpUser", "ftpPass",
		},
		RelationFields: []string{
			"app",
		},
		RelationConfigs: map[string]*mgo.DocRelation{

			"app": {
				Config:     GetAppConfig,
				DocName:    "App",
				JoinType:   "O",
				KeyInside:  "appId",
				KeyOutSide: "id",
			},
		},
		FieldFilter: map[string]*mgo.DocFieldFilter{
			"default": {
				Select: []string{},
				Omit:   []string{},
			},
		},
	}
}
